package com.hyacinth.lotterysystem.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hyacinth.lotterysystem.common.pojo.CommonResult;
import com.hyacinth.lotterysystem.dto.req.ActivityListReq;
import com.hyacinth.lotterysystem.dto.req.CreateActivityReq;
import com.hyacinth.lotterysystem.dto.resp.ActivityDetailResp;
import com.hyacinth.lotterysystem.dto.resp.ActivityListResp;
import com.hyacinth.lotterysystem.dto.resp.CreateActivityResp;
import com.hyacinth.lotterysystem.service.ActivityService;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: Yun
 * @Date: 2025/10/4
 */
@RestController
@RequestMapping("/activity")
public class ActivityController {
    private static final Logger logger = LoggerFactory.getLogger(ActivityController.class);

    @Resource
    private ActivityService activityService;

    @RequestMapping("/create")
    public CommonResult<CreateActivityResp> createActivity(@Validated @RequestBody CreateActivityReq param) {
        logger.info("创建活动 -> CreateActivityReq: {} ", param);
        return CommonResult.success(activityService.createActivity(param));
    }

    @GetMapping("/list")
    public CommonResult<IPage<ActivityListResp>> selectActivityList(ActivityListReq activityListReq) {
        logger.info("查询活动列表 -> activityListReq: {}", activityListReq);
        return CommonResult.success(activityService.selectActivityList(activityListReq));
    }

    @GetMapping("/selectByActivityId")
    public CommonResult<ActivityDetailResp> selectByActivityId(Long activityId) {
        logger.info("查看活动详情 activityId: {}", activityId);
        return CommonResult.success(activityService.selectByActivityId(activityId));
    }
}
